// var i;
// var $uI_ShopItemInfo_UIBindings = require("./UI_ShopItemInfo_UIBindings");
// var $uIView = require("./UIView");
// var $const_Hall = require("./Const_Hall");
// var $commonUtils = require("./CommonUtils");
// var $bundleConfig = require("./BundleConfig");
// var p = cc._decorator;
// var h = p.ccclass;
// var f = p.property;
// var g = p.inspector;
// var _ = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.auto_ui = null;
//         return t;
//     }
//     __extends(t, e);
//     t.prototype._show = function (e) {
//         var t = this.auto_ui;
//         t.txt_titleLabel.string = e.titleName;
//         t.sp_iconBg.spriteFrame = e.qualitySpriteFrame;
//         t.sp_iconSprite.spriteFrame = e.iconSpriteFrame;
//         if (!e.qualitySpriteFrame) {
//             this._loadRes($bundleConfig.BundleNames.Common, "res/quality/quality_1", cc.SpriteFrame).then(function (e) {
//                 t.sp_iconBg.spriteFrame = e;
//             });
//         }
//         $commonUtils.default.LimitSpriteMaxSize(t.sp_iconSprite, $const_Hall.equipIconSize);
//         t.txt_countLabel.string = e.count + "";
//         t.txt_infoLabel.string = e.infoStr;
//         t.node_videoIcon.active = e.richType == $const_Hall.RichType.视频;
//         t.node_goldIcon.active = e.richType == $const_Hall.RichType.金币;
//         t.node_diamondIcon.active = e.richType == $const_Hall.RichType.钻石;
//         t.txt_priceLabel.string = e.price + "";
//         this.clickCallBack = e.clickCallBack;
//     };
//     t.prototype._clickListener = function (e) {
//         var t = this.auto_ui;
//         switch (e) {
//             case t.btn_closeBtn:
//                 this._close();
//                 break;
//             case t.btn_clickBtn:
//                 if (this.clickCallBack) {
//                     this.clickCallBack();
//                 }
//                 this._close();
//         }
//     };
//     __decorate([f($uI_ShopItemInfo_UIBindings.default)], t.prototype, "auto_ui", void 0);
//     return __decorate([h], t);
// })($uIView.default);
// exports.default = _;


// import UI_ShopItemInfo_UIBindings from './UI_ShopItemInfo_UIBindings';
// import UIView from './UIView';
// import CommonUtils from './CommonUtils';
// import {BundleNames} from './BundleConfig';
// import { equipIconSize, RichType } from './Const_Hall';

// const { ccclass, property } = cc._decorator;

// /**
//  * @class ShopItemInfoUI
//  * @description 建议类名: ShopItemInfoComponent
//  * 处理商店物品展示的组件类
//  */
// @ccclass
// class UI_ShopItemInfo extends UIView {

//     @property(UI_ShopItemInfo_UIBindings)
//     /** 
//      * @type {UI_ShopItemInfo_UIBindings}
//      * @description 建议属性名: uiBindings
//      * 自动绑定的UI节点和组件
//      */
//     public auto_ui: UI_ShopItemInfo_UIBindings = null;

//     clickCallBack?: Function
//     /**
//      * 显示商店物品信息
//      * @param {object} itemInfo - 商品信息对象
//      * @param {string} itemInfo.titleName - 商品标题
//      * @param {cc.SpriteFrame} itemInfo.qualitySpriteFrame - 商品品质图标
//      * @param {cc.SpriteFrame} itemInfo.iconSpriteFrame - 商品图标
//      * @param {number} itemInfo.count - 商品数量
//      * @param {string} itemInfo.infoStr - 商品描述
//      * @param {number} itemInfo.richType - 商品类型
//      * @param {number} itemInfo.price - 商品价格
//      * @param {Function} itemInfo.clickCallBack - 点击回调
//      * @description 建议方法名: showItemInfo
//      */
//     public _show(itemInfo: {
//         titleName: string,
//         qualitySpriteFrame: cc.SpriteFrame,
//         iconSpriteFrame: cc.SpriteFrame,
//         count: number,
//         infoStr: string,
//         richType: number,
//         price: number,
//         clickCallBack?: Function
//     }): void {
//         const ui = this.auto_ui;
//         ui.txt_titleLabel.string = itemInfo.titleName;
//         ui.sp_iconBg.spriteFrame = itemInfo.qualitySpriteFrame;
//         ui.sp_iconSprite.spriteFrame = itemInfo.iconSpriteFrame;

//         if (!itemInfo.qualitySpriteFrame) {
//             this._loadRes(BundleNames.Common, "res/quality/quality_1", cc.SpriteFrame).then((spriteFrame) => {
//                 ui.sp_iconBg.spriteFrame = spriteFrame;
//             });
//         }

//         CommonUtils.LimitSpriteMaxSize(ui.sp_iconSprite, equipIconSize);
//         ui.txt_countLabel.string = itemInfo.count.toString();
//         ui.txt_infoLabel.string = itemInfo.infoStr;
//         ui.node_videoIcon.active = itemInfo.richType === RichType.视频;
//         ui.node_goldIcon.active = itemInfo.richType === RichType.金币;
//         ui.node_diamondIcon.active = itemInfo.richType === RichType.钻石;
//         ui.txt_priceLabel.string = itemInfo.price.toString();
//         this.clickCallBack = itemInfo.clickCallBack;
//     }

//     /**
//      * 点击事件监听器
//      * @param {cc.Event} event - 触发事件
//      * @description 建议方法名: handleClickEvent
//      */
//     public _clickListener(event: cc.Button): void {
//         const ui = this.auto_ui;

//         switch (event) {
//             case ui.btn_closeBtn:
//                 this._close();
//                 break;
//             case ui.btn_clickBtn:
//                 if (this.clickCallBack) {
//                     this.clickCallBack();
//                 }
//                 this._close();
//         }
//     }
// }

// export default UI_ShopItemInfo;

import UIShopItemInfoUIBindings from './UI_ShopItemInfo_UIBindings';
import UIViewBase from './UIView';
import CommonUtils from './CommonUtils';
import { BundleNames } from './BundleConfig';
import { equipIconSize, RichType } from './Const_Hall';

const { ccclass, property } = cc._decorator;

/**
 * @class ShopItemInfoUI
 * @description 建议类名: ShopItemInfoComponent
 * 处理商店物品展示的组件类
 */
@ccclass
class ViewShopItemInfo extends UIViewBase {

    @property(UIShopItemInfoUIBindings)
    /** 
     * @type {UI_ShopItemInfo_UIBindings}
     * @description 建议属性名: uiBindings
     * 自动绑定的UI节点和组件
     */
    public auto_ui: UIShopItemInfoUIBindings = null;

    clickCallBack?: Function;

    /**
     * 显示商店物品信息
     * @param {object} itemInfo - 商品信息对象
     * @param {string} itemInfo.titleName - 商品标题
     * @param {cc.SpriteFrame} itemInfo.qualitySpriteFrame - 商品品质图标
     * @param {cc.SpriteFrame} itemInfo.iconSpriteFrame - 商品图标
     * @param {number} itemInfo.count - 商品数量
     * @param {string} itemInfo.infoStr - 商品描述
     * @param {number} itemInfo.richType - 商品类型
     * @param {number} itemInfo.price - 商品价格
     * @param {Function} itemInfo.clickCallBack - 点击回调
     * @description 建议方法名: showItemInfo
     */
    public _show(itemInfo: {
        titleName: string,
        qualitySpriteFrame: cc.SpriteFrame,
        iconSpriteFrame: cc.SpriteFrame,
        count: number,
        infoStr: string,
        richType: number,
        price: number,
        clickCallBack?: Function
    }): void {
        const ui = this.auto_ui;
        ui.txt_titleLabel.string = itemInfo.titleName;
        ui.sp_iconBg.spriteFrame = itemInfo.qualitySpriteFrame;
        ui.sp_iconSprite.spriteFrame = itemInfo.iconSpriteFrame;

        if (!itemInfo.qualitySpriteFrame) {
            this._loadRes(BundleNames.Common, "res/quality/quality_1", cc.SpriteFrame).then((spriteFrame) => {
                ui.sp_iconBg.spriteFrame = spriteFrame;
            });
        }

        CommonUtils.limitSpriteSize(ui.sp_iconSprite, equipIconSize);
        ui.txt_countLabel.string = itemInfo.count.toString();
        ui.txt_infoLabel.string = itemInfo.infoStr;
        ui.node_videoIcon.active = itemInfo.richType === RichType.Video;
        ui.node_goldIcon.active = itemInfo.richType === RichType.Gold;
        ui.node_diamondIcon.active = itemInfo.richType === RichType.Diamond;
        ui.txt_priceLabel.string = itemInfo.price.toString();
        this.clickCallBack = itemInfo.clickCallBack;
    }

    /**
     * 点击事件监听器
     * @param {cc.Event} event - 触发事件
     * @description 建议方法名: handleClickEvent
     */
    public _clickListener(event: cc.Button): void {
        const ui = this.auto_ui;

        switch (event) {
            case ui.btn_closeBtn:
                this._close();
                break;
            case ui.btn_clickBtn:
                if (this.clickCallBack) {
                    this.clickCallBack();
                }
                this._close();
                break; // 添加缺少的 break
            default:
                console.warn("Unhandled button click: ", event);
        }
    }
}

export default ViewShopItemInfo;